package jiang;

public class Test1 implements Runnable {
    public static void main(String[] args) {
        Test1 t = new Test1();
        Thread t1 = new Thread(t, "t1");
        Thread t2 = new Thread(t, "t2");
        t1.start();
        t2.start();
    }

    @Override
    public void run() {
        method1();
        method2();
    }

    public synchronized void method1() {
        for (int i = 0; i < 999; i++) {
            System.out.println(Thread.currentThread().getName() + "--method1");
        }
    }

    public synchronized static void method2() {
        System.out.println(Thread.currentThread().getName() + "--begin method2");
        for (int j = 0; j < 9900; j++)
            for (int i = 0; i < 999999999; i++)
                ;
        System.out.println(Thread.currentThread().getName() + "--end method2");
    }
}
